package org.example.controller;
import org.example.bean.Animal;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.example.bean.Person;
@Controller
public class HelloController {
    @Autowired
    private Person person;
    @ResponseBody
    @RequestMapping("/hello")
    public Person hello() {
        return person;
    }

    @Autowired
    private Animal animal;
    @ResponseBody
    @RequestMapping("/value")
    public String getValue() {
        //必须使用autowired 去重写,animal toString 实例化后返回json
        return animal.getName();
    }
}
